#!/bin/sh -e

MYDIR=`dirname $0`
TOPDIR=`cd $MYDIR/../..; pwd`

rm -rf $TOPDIR/qt*/root/opt
install -d -m 755 $TOPDIR/qt-doc/root/opt/qt4
install -d -m 755 $TOPDIR/qt-extras/root/opt/qt4/bin

pushd $TOPDIR/compile.build/qt-copy
	make -j1 install INSTALL_ROOT=$TOPDIR/qt/root
	chown -R root:staff $TOPDIR/qt/root/opt
	find $TOPDIR/qt/root/opt -type d -name .svn -exec rm -rf {} \; || :
	find $TOPDIR/qt/root/opt -name \*.prl -exec rm -rf {} \; || :
popd
pushd $TOPDIR/qt/root/opt/qt4
	mv bin/qtdemo* $TOPDIR/qt-extras/root/opt/qt4/bin/
	mv demos examples $TOPDIR/qt-extras/root/opt/qt4/
	mv doc $TOPDIR/qt-doc/root/opt/qt4/
	pushd lib/pkgconfig
		$TOPDIR/qt/resources/postprocess-pkgconfig-files.sh .
	popd
	pushd lib
		perl -pi -e "s,-L$TOPDIR/[^ ]*/lib ,,gs" *.la
	popd
popd

pushd $TOPDIR
	rm -rf kde-mac/qt*
	make -j1 kde-mac/qt.torrent kde-mac/qt-doc.torrent kde-mac/qt-extras.torrent
popd
